package com.atguigu.qqzone.controller;

import com.atguigu.qqzone.pojo.Reply;
import com.atguigu.qqzone.pojo.Topic;
import com.atguigu.qqzone.pojo.UserBasic;
import com.atguigu.qqzone.service.impl.ReplyServiceImpl;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * @ClassName: ReplyController
 * @Description:
 * @Author: wty
 * @Date: 2022/12/10
 */

public class ReplyController {
    private ReplyServiceImpl replyServiceImpl;

    public String addReply(String content, Integer topicId, HttpSession session) {
        // 当前作者
        UserBasic author = (UserBasic) session.getAttribute("userBasic");


        Reply reply = new Reply(content, new Date(), author, new Topic(topicId));

        replyServiceImpl.addReply(reply);

        return "redirect:topic.do?operate=topicDetail&id=" + topicId;

    }

    public String delReply(Integer replyId, Integer topicId) {
        replyServiceImpl.delReply(replyId);
        return "redirect:topic.do?operate=topicDetail&id=" + topicId;
    }

}
